home *** CD-ROM | disk | FTP | other *** search
- Path: surfnet.nl!sun4nl!xs4all!usenet
- From: Ronald Werring <ronaldw@xs4all.nl>
- Newsgroups: comp.lang.c++
- Subject: Q: implementing streambuf::underflow() method
- Date: 22 Feb 1996 20:21:42 GMT
- Organization: XS4ALL, networking for the masses
- Message-ID: <4gij8m$pi7@news.xs4all.nl>
- NNTP-Posting-Host: asd06-14.dial.xs4all.nl
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
-
- I want to make a subclass of the streambuf class to
- implement a different buffering strategy for an istream.
- I use Visual-C++ (1.5 and 4.0).
-
- My question: "When is underflow() called? Only when
- the buffer is empty or for every character?"
-
- (part of) my source:
- int MyStreamBuf::underflow()
- {
- // is this line necessary?
- if (in_avail()) return *gptr();
-
- // setting new get pointers with setg
- // when buffer is empty
- char* gptr = m_text[m_regel]; // get buffer from stringarray
- if (gptr == 0) return EOF;
- int len = strlen(gptr);
- setg(gptr, gptr, gptr+len);
- m_regel++;
-
- // return first of new buffer
- return *gptr;
- }
-
- Anybody experienced?
-
- Ronald Werring
-
-
-
-